<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>组件定义</title>
  <script src="../vue.js"></script>
</head>
<body>
  <div id="app">
    <child :title="title" :obj="obj"></child>
    <button @click="handleClick">change title</button>
    <button @click="changeObj">change obj</button>
    <div>
      {{obj}}
    </div>
  </div>
  <script type="module">
    import './child.js'
    new Vue({
      el: '#app',
      data: {
        title: 'hello',
        obj: {
          x: 0,
          y: 1,
          z: {
            aaa: 100
          }
        }
      },
      mounted() {
        console.log('parent mounted.')
      },
      updated() {
        console.log('parent updated.')
      },
      methods: {
        handleClick() {
          this.title = 'hello'
        },
        changeObj() {
          // this.obj.x = 100
          this.obj.z.aaa = 200
        }
      },
    })
  </script>
</body>
</html>